package com.bitoon.basketdudes.jpa;

/**
 * @author paco FELC 2010
 */

import java.io.Serializable;
import javax.persistence.EmbeddedId;
import javax.persistence.Entity;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;

/**
 * @author pacoFELC
 */
@Entity
@Table(name = "temporada_trofeo", schema = "basket")
@NamedQueries({
    @NamedQuery(name = "TemporadaTrofeo.findAll", query = "SELECT t FROM TemporadaTrofeo t"),
    @NamedQuery(name = "TemporadaTrofeo.findByTemporadaId", query = "SELECT t FROM TemporadaTrofeo t WHERE t.temporadaTrofeoPK.temporadaId = :temporada_id"),
    @NamedQuery(name = "TemporadaTrofeo.findByTrofeoId", query = "SELECT t FROM TemporadaTrofeo t WHERE t.temporadaTrofeoPK.trofeoId = :trofeoId"),
    @NamedQuery(name = "TemporadaTrofeo.findByPosicion", query = "SELECT t FROM TemporadaTrofeo t WHERE t.temporadaTrofeoPK.posicion = :posicion")})
public class TemporadaTrofeo implements Serializable {
    private static final long serialVersionUID = 1L;
    @EmbeddedId
    protected TemporadaTrofeoPK temporadaTrofeoPK;
    @JoinColumn(name = "temporada_id", referencedColumnName = "id", insertable = false, updatable = false)
    @ManyToOne(optional = false)
    private Temporada temporada;
    @JoinColumn(name = "trofeo_id", referencedColumnName = "id", insertable = false, updatable = false)
    @ManyToOne(optional = false)
    private Trofeo trofeo;

    public TemporadaTrofeo() {
    }

    public TemporadaTrofeo(TemporadaTrofeoPK temporadaTrofeoPK) {
        this.temporadaTrofeoPK = temporadaTrofeoPK;
    }

    public TemporadaTrofeo(int temporadaId, int trofeoId, short posicion) {
        this.temporadaTrofeoPK = new TemporadaTrofeoPK(temporadaId, trofeoId, posicion);
    }

    public TemporadaTrofeoPK getTemporadaTrofeoPK() {
        return temporadaTrofeoPK;
    }

    public void setTemporadaTrofeoPK(TemporadaTrofeoPK temporadaTrofeoPK) {
        this.temporadaTrofeoPK = temporadaTrofeoPK;
    }

    public Temporada getTemporada() {
        return temporada;
    }

    public void setTemporada(Temporada temporada) {
        this.temporada = temporada;
    }

    public Trofeo getTrofeo() {
        return trofeo;
    }

    public void setTrofeo(Trofeo trofeo) {
        this.trofeo = trofeo;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (temporadaTrofeoPK != null ? temporadaTrofeoPK.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof TemporadaTrofeo)) {
            return false;
        }
        TemporadaTrofeo other = (TemporadaTrofeo) object;
        if ((this.temporadaTrofeoPK == null && other.temporadaTrofeoPK != null) || (this.temporadaTrofeoPK != null && !this.temporadaTrofeoPK.equals(other.temporadaTrofeoPK))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "paco.TemporadaTrofeo[temporadaTrofeoPK=" + temporadaTrofeoPK + "]";
    }

}
